﻿using System;
using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.IO;

namespace TecHappy.WindowsPhone.Toolkit
{
    public static partial class WriteableBitmapExtensions
    {
        private const int SizeOfArgb = 4;
        public static WriteableBitmap Clone(this WriteableBitmap bmp)
        {
            var result = new WriteableBitmap(bmp.PixelWidth, bmp.PixelHeight);
            Buffer.BlockCopy(bmp.Pixels, 0, result.Pixels, 0, bmp.Pixels.Length * SizeOfArgb);
            return result;
        }
    }
}
